home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / HOST.SRC < prev    next >
Text File  |  1992-07-03  |  18KB  |  689 lines

  1. ;    trace on        ; Debugging
  2. ;
  3. ; ----- COM-AND Scripted host mode ----------------------------------
  4. ;
  5. ;    Goals:
  6. ;    o    Must autodetect caller's baud rate
  7. ;    o    Must work correctly for modems reporting true CD and otherwise.
  8. ;    o    Must log all activity
  9. ;
  10. ;    Functions:
  11. ;    o    Passworded log-on
  12. ;    o    DIR of current directory
  13. ;    o    CHDIR command
  14. ;    o    UP and DOWNLOADS
  15. ;    o    Graphical path display (using P/D TREED program)
  16. ;    o    Passworded DOS access (dangerous!)
  17. ;    o    Passworded drop-to-DOS using a doorway function
  18. ;
  19. ;    Commenced: 10/29/87 R.McG
  20. ;    Updated:    2/--/89 R.McG
  21. ;           10/--/89 R.McG  ZMODEM added
  22. ;    Ver 1.1:   11/--/90 R.McG  HOSETUP added
  23. ;            6/--/91 R.McG  DROPDOS added
  24. ;    --------------------------------------------------------------
  25. ;    Data for this script are established through the HOSETUP script.
  26. ;    The drop-to-DOS requires a doorway function (such as DOORWAY,
  27. ;    by Marshsall Dudley), and the script HOSTART.  The only other
  28. ;    file requisite to this HOST script is the TREED p/d utility.
  29. ;    --------------------------------------------------------------
  30. ;
  31. ;    Initialize
  32. ;
  33.     LEGEND "Scripted HOST mode (1.1).  Press ESC to exit."
  34. ;
  35. ;    Set default values (in case HOSTDAT does not exist)
  36. ;
  37.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  38.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for HOST
  39.     S22 = "****"                    ; Set default logon password
  40.     S23 = "xxxx"                    ; Set default DOS password
  41.     S24 = ""                        ; Drop to DOS command
  42. ;
  43. ;    Initialize COM related values (This is done here to allow HOSTDAT
  44. ;    ... edits to override these settings)
  45. ;
  46.     SET PARITY NONE         ; fixed no parity
  47.     SET DATA 8            ; fixed 8 data bits
  48.     SET STOP 1            ; fixed 1 stop bit
  49.     SET MASK ON            ; accept 7 or 8 bits
  50.     SET CR_IN CR_LF         ; Display received c/rs as a cr/lf
  51.     SET ASCII UP_LF LF        ; Send LFs
  52.     SET SOFTFLOW ON         ; Allow XON/XOFF
  53. ;
  54. ;    Replace above values from HOSTDAT, if that script exists
  55. ;
  56.     IF ISSC "HOSTDAT" FCALL "HOSTDAT"
  57. ;
  58. ;    Initialize variables that must be constant
  59. ;
  60.     S0 = S22            ; Set to our subdirectory
  61.     S3 = S23            ; Set subdir for files
  62.     SUBDIR S29            ; Read current subdir
  63.     DLDIR S28            ; Read current download subdir
  64. ;
  65. ;    Set initial values that do not change port setting
  66. ;
  67.     LOG MARK ON            ; Timestamp logging
  68.     CLOG "* Host script loaded"
  69.     ON ESCAPE GOSUB End        ; Exit routine
  70.     SET INAFTER OFF         ; Turn off init after hangup
  71.     SET ALARM OFF            ; Turn off alarm
  72.     SET ATIME 1            ; Set alarm time to 1 second
  73. ;
  74. ;    If this is a restart, pickup at the main prompt
  75. ;
  76.     SET PORT S20(0:3)        ; Starting port
  77.     IF FCALLED and ISFILE "HOSTTEMP.BAT"
  78.        SET RECHO ON         ; Restart - need to reenable
  79.        LOG OPEN "HOSTLOG"           ; .. reenable
  80.        CLOG "* Return from drop-to-DOS"
  81.        GOTO Main_Prompt
  82.        ENDIF
  83. ;
  84. ;    Initialize values that change port setting, and start a new call
  85. ;
  86.     SET BAUD S20(5:8)        ; Starting speed
  87.     TRANSMIT "_MESCAPE"             ; Initialize modem (modem escape)
  88.     GOTO Restart            ; Branch around subroutines
  89. ;
  90. ; -----------------------------------------------------------------------
  91. ;    Subroutine: End of HOST
  92. ; -----------------------------------------------------------------------
  93. ;
  94. End:
  95.     HANGUP                ; Hangup the phone
  96.     CLOG "* HOST script terminated" ; Log completion
  97.     SET DLDIR S28            ; Reset dldir
  98.     CHDIR S29            ; Reset to default directory
  99.     RESET                ; Reset default values
  100.     CLEAR                ; Clear screen
  101.     MESS "HOST terminated... type Alt-X to exit COM-AND^M^J^M^J"
  102.     TRAN "_MINIT"                   ; Initialize modem from defaults
  103.     DELETE "\HOSTTEMP.TXT"          ; Cleanup
  104.     EXIT                ; Exit
  105. ;
  106. ;    Subroutine: Read from the caller into S9
  107. ;    .. This handles 'disconnect' and timeouts.
  108. ;
  109. Read_Comm:
  110.     RGET S9 80 180        ; wait for a connection
  111.     IF NOT CONNECTED    ; If modem reports CD dropped
  112.        GOTO Disconnect    ; Goto disconnect
  113.        ENDIF
  114.  
  115.     IF NOT SUCCESS        ; If timeout on the RGET
  116.        GOTO Timeout     ; .. issue message and disconnect
  117.     ENDIF
  118.  
  119.     FIND S9 "NO CARRIER"    ; Test for message from modem
  120.     IF FOUND        ; If modem didn't report 'CD' true
  121.        GOTO Disconnect    ; Goto disconnect
  122.        ENDIF
  123.  
  124.     SET FLAG(0) OFF     ; Report to caller
  125.     RETURN            ; Return with text in S9
  126. ;
  127. ;    Timeout on the call
  128. ;
  129. Timeout:
  130.     TRAN "^M^J... autodisconnect due to timeout"
  131.     MESSAGE "^M^J... autodisconnect due to timeout"
  132.     GOTO RComm_Exit     ; Exit cycle in the usual manner
  133. ;
  134. ;    Disconnect was reported.
  135. ;
  136. Disconnect:
  137.     MESSAGE  "^M^JCaller disconnected"
  138. ;
  139. ;    Read_Comm error exit
  140. ;
  141. RComm_Exit:
  142.     SET FLAG(0) ON        ; Report to caller
  143.     RETURN            ; Return to the caller
  144. ;
  145. ;    Usages:
  146. ;      S0 -> main password
  147. ;      S1 -> ID
  148. ;      S2 -> Default drive/subdir
  149. ;      S3 -> DOS password
  150. ;      S8 -> File name buffer
  151. ;      S9 -> General read buffer
  152. ;
  153. ;    Begin the sequence...
  154. ;
  155. Restart:
  156.     CHDIR S29        ; Reset to default drive
  157.     SET RECHO OFF        ; Turn off echo for us
  158.     SET RDISP OFF        ; Disable display of rcvd chars
  159.     CLEAR            ; Clear screen
  160.     LOCATE 0,0        ; Set to home
  161. ;
  162. ;    Go into auto answer (echo off, answer on 3rd)
  163. ;    Also: Return result codes, word form, with CONNECT 1200
  164. ;
  165. ;
  166.     HANGUP            ; HANGUP and leave modem in cmd mode
  167.     MESSAGE "^M^JWaiting...!"
  168.     PAUSE 3         ; Wait 3 secs
  169.     SET BAUD S20(5:8)    ; Starting speed
  170.     TRANSMIT S21        ; Transmit modem initialization
  171. ;
  172. ;    Wait for a connect
  173. ;
  174. WAIT_IT_OUT:
  175.     RGET S9 80 180
  176.     IF NOT SUCCESS
  177.        GOTO Wait_IT_Out
  178.        ENDIF
  179.  
  180.     FIND S9 "NO CARRIER"
  181.     IF FOUND
  182.        GOTO Restart
  183.        ENDIF
  184.  
  185.     FIND S9 "CONNECT"
  186.     IF NOT FOUND
  187.        GOTO WAIT_IT_OUT
  188.        ENDIF
  189. ;
  190. ;    Connection established: Adjust our linespeed if need be
  191. ;
  192.     GOSUB AutoBaud        ; Change rate according to CONNECT MSG
  193. ;
  194. ;    Issue a greeting
  195. ;
  196.     PAUSE 2         ; Let the modem settle
  197.     RFLUSH            ; Clear junk
  198.     TRAN "^M^JThe Flying Scotsman greets you!!^M^J"
  199.     SET RECHO ON        ; Turn on echo (back to caller)
  200.     SET RDISP ON        ; Turn on display of rcvd chars
  201.     LOG OPEN "HOSTLOG"
  202. ;
  203. ;    Request an ID
  204. ;
  205. ID_Query:
  206.     MESS "^M^JID prompt: "  ; Local console indicator
  207.     TRANSMIT "^M^JEnter your ID: "
  208.  
  209.     GOSUB Read_Comm     ; Read into S9
  210.     IF FLAG(0)        ; If first flag rtns set
  211.        GOTO Exit        ; .. disconnect and start over
  212.        ENDIF        ; ..
  213.  
  214.     SWITCH S9
  215.        CASE "_NULL"         ; Test for nothing entered
  216.           TRAN "You must be someone^M^J"
  217.           GOTO Exit     ; Don't let noone in
  218.       ENDCASE        ; End of ridicule
  219.     ENDSWITCH        ; End of ID test
  220.  
  221.     CLOG "* Host mode logon by "*S9
  222. ;
  223. ;    Request a password
  224. ;
  225.     TRANSMIT "^M^JEnter your password: "
  226.     LOG SUSPEND
  227.     SET RECHO OFF        ; Turn of echo of received text
  228.     SET RDISPLAY OFF    ; Turn off echo to console too
  229.  
  230.     GOSUB Read_Comm     ; Read into S9
  231.     IF FLAG(0)        ; If first flag rtns set
  232.        GOTO Exit        ; .. disconnect and start over
  233.        ENDIF        ; ..
  234.  
  235.     LOG RESUME        ; Restore logging
  236.     SET RECHO ON        ; Restore echo
  237.     SET RDISPLAY ON     ; Turn on echo to console again
  238. ;
  239. ;    Test for the main password
  240. ;
  241.     SWITCH S9
  242.        CASE S0        ; Test for match with S0
  243.           TRANSMIT "^M^J"   ; OK - good password
  244.        ENDCASE        ; End match with S0
  245.        DEFAULT        ; Not one of the above
  246.           TRANSMIT "Sorry , but you're not authorized."
  247.           GOTO Exit     ; And disconnect
  248.        ENDCASE        ; End of DEFAULT
  249.     ENDSWITCH
  250. ;
  251. ;    Now - do something
  252. ;
  253. Main_Prompt:
  254.     MESS "^M^JMain prompt: "; Local console indicator
  255.     TRAN "^M^JC)hdir F)ilelist, P)athlist, U)pload, D)ownload, or E)xit: "
  256.  
  257.     GOSUB Read_Comm     ; Read into S9
  258.     IF FLAG(0)        ; If first flag rtns set
  259.        GOTO EXIT        ; .. disconnect and start over
  260.        ENDIF        ; ..
  261.  
  262.     SWITCH S9        ; Test the entry
  263.        CASE "C"
  264.           GOTO CHDIR
  265.        ENDCASE
  266.  
  267.        CASE "D"
  268.           GOTO DOWNLOAD
  269.        ENDCASE
  270.  
  271.        CASE "E"
  272.           TRAN "Ok... bye^M^J"
  273.           GOTO EXIT
  274.        ENDCASE
  275.  
  276.        CASE "F"
  277.           GOTO FILELIST
  278.        ENDCASE
  279.  
  280.        CASE "P"
  281.           GOTO PATHLIST
  282.        ENDCASE
  283.  
  284.        CASE "U"
  285.           GOTO UPLOAD
  286.        ENDCASE
  287.  
  288.        CASE "X"
  289.           GOTO DOS
  290.        ENDCASE
  291.  
  292.        CASE "Y"
  293.           GOTO DROPDOS
  294.        ENDCASE
  295.  
  296.        CASE "OFF"
  297.           TRAN "Ok... bye^M^J"
  298.           GOTO EXIT
  299.        ENDCASE
  300.     ;
  301.     ;    Default case for typists
  302.     ;
  303.        DEFAULT
  304.           FIND S9 "CHDIR"   ; Try for larger
  305.           IF FOUND        ; If entry contained "CHDIR"
  306.          GOTO CHDIR
  307.          ENDIF
  308.